package com.itwill.ecom.company;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/Company")
public class CompanyController {
	@Autowired
	CompanyService service;
	
	
	public CompanyController(){
		System.out.println("### CompanyController 생성자 ###");
	}
	
	//회사 생성하기.
	@RequestMapping(value = "/Write", method = RequestMethod.GET)
	public String WriteTest(CompanyBeans company) {
		service.createCompany(company);
		System.out.println("쓰기 테스트 시작!");
		
		
		return "Company/WriteTest";
	}

	//회사 전체리스트 가져오기.
	@RequestMapping(value = "/AllList", method = RequestMethod.GET)
	public String AllListTest(HttpServletRequest request, @ModelAttribute List<CompanyBeans> companyList, Model model) {
		System.out.println("전체 리스트 테스트 시작!");
		companyList = service.getAllCompany();
		model.addAllAttributes(companyList);
		return "Company/ListTest";
	}


	@RequestMapping(value = "/FindByNo", method = RequestMethod.GET)
	public String NoListTest() {
		System.out.println("번호 리스트 테스트 시작!");
		return "Company/NoListTest";
	}

	@RequestMapping(value = "/Update", method = RequestMethod.GET)
	public String UpdateRecommendTest() {
		System.out.println("수정 테스트 시작!");
		return "Company/UpdateTest";
	}

	@RequestMapping(value = "/Delete", method = RequestMethod.GET)
	public String DeleteTest() {
		System.out.println("삭제 테스트 시작!");
		return "Company/DeleteTest";
	}
}